package cn.zust.edu.cn;
/**
 * 
 * @author czg
 * @since 2023/3/7 10:50
 */
public class Rectangle implements IShape {
	private Point ptTopLeft;
	private Point ptTopRight;
	private int width;
	private int height;

	public Rectangle() {
		this(new Point(), 0, 0);
	}

	public Rectangle(Point topLeft, int height, int width) {
		this.ptTopLeft = topLeft;
		this.width = width;
		this.height = height;
		this.ptTopRight = new Point(ptTopLeft.getX() + width, ptTopLeft.getY());
	}

	public double perimeter() {
		return 2 * (width + height);
	}

	public double area() {
		return width * height;
	}

	public void draw() {
		for (int i = 0; i < height; i++) {
			for(int j = 0; j < width; j++) {
				if (i==0||i==height-1||j==0||j==width-1){
					System.out.print("*");
				}else{
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}
